package com.cjl.eater.controller.v1;

import com.cjl.common.dtos.PageDto;
import com.cjl.common.dtos.ResponseResult;
import com.cjl.eater.dtos.EaterFoodRelationsDto;
import com.cjl.eater.dtos.EaterInfoDto;
import com.cjl.eater.service.EaterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author cjl
 * @version v1.0
 * @description TODO
 * @createTime 2023/2/9 14:07
 */
@Api(value = "EaterController",description = "用户可以填写个人信息")
@RestController
@RequestMapping("/api/eater")
public class EaterController {
    @Autowired
    EaterService eaterService;

    @ApiOperation(value = "修改个人信息",notes = "可以对昵称，性别，出生日期进行修改")
    @PostMapping("modifyEaterInfo")
    public ResponseResult modifyEaterInfo(@RequestBody EaterInfoDto eaterInfoDto) {
        return eaterService.modifyEaterInfo(eaterInfoDto);
    }

    @ApiOperation(value = "食客行为",notes = "可以对菜品点赞，收藏")
    @PostMapping("saveEaterBehavior")
    public ResponseResult saveEaterBehavior(@RequestBody EaterFoodRelationsDto eaterFoodRelationsDto){
        return eaterService.saveEaterBehavior(eaterFoodRelationsDto);
    }

    @ApiOperation("根据菜名查询菜品")
    @GetMapping("/searchFood")
    public ResponseResult searchFood(@RequestParam("foodName") String foodName) throws Exception{
        return eaterService.searchFood(foodName);
    }
    @ApiOperation("菜品列表")
    @PostMapping("/foodList")
    public ResponseResult foodList(@RequestBody PageDto pageDto){
        return eaterService.foodList(pageDto);
    }
}
